﻿using NavigateDemo.Services;

namespace NavigateDemo.ViewModels
{
    public partial class MainViewModel : ViewModelBase
    {
        private readonly NavigationService navigator;

        [ObservableProperty]
        private ViewModelBase? currentViewModel;

        // 单例的导航服务注册回调事件
        public MainViewModel(NavigationService navigationService)
        {
            navigator = navigationService;
            navigator.CurrentViewModelChanged += () =>
            {
                CurrentViewModel = navigationService.CurrentViewModel;
            };

            navigator.NavigateTo<LoginViewModel>();
        }
    }
}
